package com.IClass.IActivity;

import com.IClass.App.R;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TabHost;

public class IMainViewActivity extends TabActivity  implements OnCheckedChangeListener {
	/** Called when the activity is first created. */
	private TabHost mHost;
    private Intent iAsk;
    private Intent iLook;
    private Intent iBox;
    private Intent iUser;
    private RadioGroup mainTab;
    public static String IEAT = "ieat";
    public static String IOTER = "iother";
    public static String IME = "ime";
	 protected void onCreate(Bundle paramBundle)
	  {
	    super.onCreate(paramBundle);
		
	    requestWindowFeature(Window.FEATURE_NO_TITLE);  
	    setContentView(R.layout.iclass_activity);
 
	    mainTab=(RadioGroup)findViewById(R.id.main_tab);  
        mainTab.setOnCheckedChangeListener(this);  
        
        
        setupIntent();
	}
	 @Override
	 public void onCheckedChanged(RadioGroup group, int checkedId) {
		 switch(checkedId){  
	        case R.id.radio_button0:  
	            this.mHost.setCurrentTabByTag(IEAT);  
	            break;  
	        case R.id.radio_button1:  
	            this.mHost.setCurrentTabByTag(IOTER);  
	            break;  
	        case R.id.radio_button2:  
	            this.mHost.setCurrentTabByTag(IME);  
	            break; 
//	        case R.id.radio_button3:  
//	            this.mHost.setCurrentTabByTag("iUser");  
//	            break;
	        }  
	    }

	    private void setupIntent() {
	        this.mHost = getTabHost();

	        iAsk = new Intent(this, IAskActivity.class);  
	        mHost.addTab(mHost.newTabSpec(IEAT)  
	                .setIndicator(IEAT, getResources().getDrawable(R.drawable.icon_1_n))  
	                .setContent(iAsk));  
	          
	        iLook = new Intent(this, ILookActivity.class);  
	        mHost.addTab(mHost.newTabSpec(IOTER)  
	                .setIndicator(IOTER, getResources().getDrawable(R.drawable.icon_2_n))  
	                .setContent(iLook));  
	          
//	        iBox = new Intent(this, IBoxActivity.class);  
//	        mHost.addTab(mHost.newTabSpec("iBox")  
//	                .setIndicator(getResources().getString(R.string.ibox), getResources().getDrawable(R.drawable.icon_3_n))  
//	                .setContent(iBox));  
	          
	        iUser = new Intent(this, IRegisterActivity.class);  
	        mHost.addTab(mHost.newTabSpec(IME)  
	                .setIndicator(IME, getResources().getDrawable(R.drawable.icon_4_n))  
	                .setContent(iUser));  
	          

//	        localTabHost.addTab(buildTabSpec("search_tab", R.string.menu_search,
//	                R.drawable.icon_4_n, this.mSearchIntent));
//
//	        localTabHost.addTab(buildTabSpec("more_tab", R.string.more,
//	                R.drawable.icon_5_n, this.mMoreIntent));

	    }

	    private TabHost.TabSpec buildTabSpec(String tag, int resLabel, int resIcon,
	            final Intent content) {
	        return this.mHost.newTabSpec(tag).setIndicator(getString(resLabel),getResources().getDrawable(resIcon)).setContent(content);
	    }


}
